package com.olympia.myapp.server;

import com.olympia.myapp.util.Constants;

public class URLServer {
	private static String URL = "http://www.azsoft.com.vn/myapp/nauan/server.ashx?";
	public static String URLSERVER = "http://www.azsoft.com.vn/myapp/nauan";
	public static final String DETAIL = "/server.ashx?";
	private static final String ACTION = "action=";
	private static final String VERSION = "&version=";

	private static final String KEY_REGIS = "OLPASIGNUP";
	private static final String KEY_LOGIN = "OLPASIGNIN";
	private static final String KEY_TOPTEN = "OLPATOP";
	private static final String KEY_OLPASTART = "OLPASTART";
	private static final String KEY_OLPAUPSCORE = "OLPAUPSCORE";
	private static final String KEY_OLPAPAYCARD = "OLPAPAYCARD";
	private static final String KEY_OLPAQUEST = "OLPAQUEST";
	private static final String KEY_OLPARESET = "OLPARESET";

	/*
	 * Kết nối đến server để xem có đc không
	 * 
	 * @return
	 */
	public String connectServer() {
		return URL + ACTION + "ADDSVOLPA";
	}

	/**
	 * Link login
	 * 
	 * @param version
	 * @param email
	 * @param pass
	 * @return
	 */
	public String login(String version, String email, String pass) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_LOGIN);
		strBuf.append(VERSION).append(version);
		strBuf.append("&email=").append(email);
		strBuf.append("&pass=").append(pass);

		return strBuf.toString();
	}

	/**
	 * Đăng ký
	 * 
	 * @param version
	 * @param fullname
	 * @param email
	 * @param pass
	 * @return
	 */
	public String regis(String version, String fullname, String email,
			String pass) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_REGIS);
		strBuf.append(VERSION).append(version);
		strBuf.append("&fullname=").append(fullname);
		strBuf.append("&email=").append(email);
		strBuf.append("&pass=").append(pass);

		return strBuf.toString();
	}

	/**
	 * Đọc danh sách ng chơi cao điểm nhất
	 * 
	 * @param email
	 * @return
	 */
	public String getTopTen(String email) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_TOPTEN);
		strBuf.append("&email=").append(email);

		return strBuf.toString();
	}

	/**
	 * Ghi nhận 1 lần chơi
	 * 
	 * @param email
	 * @return
	 */
	public String acceptPlay(String email) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_OLPASTART);
		strBuf.append("&email=").append(email);

		return strBuf.toString();
	}

	/**
	 * Ghi nhận điểm số đã lần chơi
	 * 
	 * @param email
	 * @return
	 */
	public String acceptScore(String email, String score) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_OLPAUPSCORE);
		strBuf.append("&email=").append(email);
		strBuf.append("&score=").append(score);

		return strBuf.toString();
	}

	/**
	 * nap xu vao tai khoan
	 * 
	 * @param email
	 * @return
	 */
	public String addCoin(String email, String cardno, String serino, int telco) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_OLPAPAYCARD);
		strBuf.append("&version=").append(Constants.VERSION);
		strBuf.append("&email=").append(email);
		strBuf.append("&cardno=").append(cardno);
		strBuf.append("&serino=").append(serino);
		strBuf.append("&telco=").append(telco);

		return strBuf.toString();
	}

	/**
	 * nap xu vao tai khoan
	 * 
	 * @param email
	 * @return
	 */
	public String getAllQuestion(String version, String email, String pass) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_OLPAQUEST);
		strBuf.append("&version=").append(version);
		strBuf.append("&email=").append(email);
		strBuf.append("&pass=").append(pass);

		return strBuf.toString();
	}

	/**
	 * chơi lại
	 * 
	 * @param version
	 * @param email
	 * @param pass
	 * @return
	 */
	public String playAgain(String version, String email) {
		StringBuffer strBuf = new StringBuffer(URLSERVER + DETAIL);
		strBuf.append(ACTION).append(KEY_OLPARESET);
		strBuf.append("&version=").append(version);
		strBuf.append("&email=").append(email);

		return strBuf.toString();
	}
}
